package cn.edu.cqupt.cxcy.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.edu.cqupt.cxcy.dto.TeamImpl;
import cn.edu.cqupt.cxcy.model.Member;

/**
 * Servlet implementation class TeamMemberInfoById
 */
@WebServlet("/TeamMemberInfoById")
public class TeamMemberInfoById extends HttpServlet {
	private static final long serialVersionUID = 1L;
	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		this.doPost(request, response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		response.setCharacterEncoding("utf-8");
	    int memberId = Integer.valueOf(request.getParameter("id"));
	    TeamImpl teamImpl = new TeamImpl();
	    Member member = null;
	    member = teamImpl.getMemberInfoById(memberId);
	    PrintWriter out = response.getWriter();
	    if(member != null){
	    	out.write("{\"m_name\":\""+member.getM_name()+"\",\"m_sex\":\""+member.getM_sex()+"\",\"m_email\":\""+member.getM_email()+"\",\"m_tel\":\""+member.getM_tel()+"\",\"m_school\":\""+member.getM_school()+"\",\"m_college\":\""+member.getM_college()+"\",\"m_no\":\""+member.getM_no()+"\",\"m_type\":\""+member.getM_type()+"\",\"m_logo\":\""+member.getM_logo()+"\",\"m_explain\":\""+member.getM_explain()+"\",\"success\":\"true\",\"response\":true,\"m_id\":\""+member.getM_id()+"\"}");
	    	//out.write("{\"m_name\":"+"\"chenchuan\""+",\"m_sex\":"+"\"nan\""+",\"m_email\":"+"\"1138342391@qq.com\""+",\"m_tel\":"+"\"1896474255\""+",\"m_school\":"+"\"重庆邮电大学\""+",\"m_college\":"+"\"计算机\""+",\"m_no\":"+"\"25323232323\""+",\"m_type\":"+"\"队长\""+",\"m_logo\":"+"\"hehe\""+",\"m_explain\":"+"\"可以的\""+",\"success\":\"true\",\"response\":\"true\"}");;
	    	out.flush();
	    	}
//	    }else{
//	    	out.write("{\"success\":false}");
//	    }
	    //System.out.println();
	    out.close();
		
	}

}
